package com.qf.smsplatform.controller;
/*2021/11/3*/

import com.github.pagehelper.PageInfo;
import com.qf.smsplatform.dto.R;
import com.qf.smsplatform.pojo.TMenu;
import com.qf.smsplatform.service.TMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @YuTao
 */

@RestController
@RequestMapping("/menu")//查询访问地址信息的controller
@Api(tags = "访问地址表Controller")
public class TMenuController  {

    private TMenuService tMenuService;
    @Autowired
    public void settMenuService(TMenuService tMenuService) {
        this.tMenuService = tMenuService;
    }

    @GetMapping("/page")//分页显示访问地址相关信息
    @ApiOperation("进行分页查询")
    public R selectPage(int pageNum, int pageSize){
        PageInfo<TMenu> pageInfo = tMenuService.selectPage(pageNum, pageSize);
        return R.setOk(pageInfo);
    }
    @GetMapping("/selectOne")//根据URL查询单条的访问地址信息
    @ApiOperation("查询单条数据")
    public R selectMenuByUel(String url){
        TMenu tMenu = tMenuService.selectMenuByUrl(url);
        return R.setOk(tMenu);
    }
    @PostMapping("/update")//对访问地址信息进行修改，可以修改地址访问权限
    @ApiOperation("修改地址信息")
    public R updateTMenu(TMenu tMenu){
        tMenuService.updateTMenu(tMenu);
        return R.setOk();
    }
    @PostMapping("/insert")//添加可以访问的地址信息
    @ApiOperation("添加一条地址信息")
    public R insertTMenu(TMenu tMenu){
        tMenuService.insertTMenu(tMenu);
        return R.setOk();
    }


}
